package com.shigui.news.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shigui.news.dao.CategoryDao;
import com.shigui.news.dao.NewsDao;
import com.shigui.news.enums.ResponseCode;
import com.shigui.news.exception.CategoryException;
import com.shigui.news.model.Category;
import com.shigui.news.model.News;
import com.shigui.news.model.User;
import com.shigui.news.service.CategoryService;
@Service("categoryService")
public class CategoryServiceImpl implements CategoryService {

	@Autowired
	private CategoryDao categoryDao;
	@Autowired
	private NewsDao newsDao;
	
	@Override
	public Category selectById(Integer cateId) {

		Category category = categoryDao.selectById(cateId);
		
		return category;
	}

	@Override
	public List<Category> select(String sql,Integer page, Integer count) {
		// TODO Auto-generated method stub
		return categoryDao.select(sql, page, count);
	}

	@Override
	public void insert(Category category) {

		categoryDao.insert(category);
	}

	@Override
	public void update(User user,Category category) {

		if(user == null){
		
		throw new CategoryException(ResponseCode.CATEGORY_ADD);
		
		}
		
		categoryDao.update(category);
		
	}

	@Override
	public void delete(User user, Category category) {
		
		
		
		if(user == null){
			
			throw new CategoryException(ResponseCode.CATEGORY_ADD);
		}
	

		categoryDao.delete(category);
	}

	
	@Override
	public Category select(Integer cate_Id, String sql) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Category> select() {
		
		
		return categoryDao.select();
	}

	
	
	

}
